package com.example.bms.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.bms.entity.Student;
import com.example.bms.mapper.StudentMapper;
import com.example.bms.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * @apiNote 查询学生成绩
 * @author 杨雨恒
 * @email 1627856348@qq.com
 * @since 1.0.0
 */
@Service
@Transactional
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;


    /**
     * @apiNote 分页查询所有学生
     * @param page 页数
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return IPage<Student>
     * @since 1.0.0
     */
    @Override
    public IPage<Student> findAll(Page<Student> page) {
        return studentMapper.findAll(page);
    }


    /**
     * @apiNote 根据学生Id查询学生
     * @param studentId 学生Id
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return Student
     * @since 1.0.0
     */
    public Student findById(Integer studentId) {
        return studentMapper.findById(studentId);
    }


    /**
     * @apiNote 删除学生
     * @param studentId 学生Id
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return int类型，受影响的条数
     * @since 1.0.0
     */
    @Override
    public int deleteById(Integer studentId) {
        return studentMapper.deleteById(studentId);
    }


    /**
     * @apiNote 修改学生信息
     * @param student 学生实体类
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return int类型，受影响的条数
     * @since 1.0.0
     */
    @Override
    public int update(Student student) {
        return studentMapper.update(student);
    }


    /**
     * @apiNote 更新密码
     * @param student 学生实体类
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return int类型，受影响的条数
     * @since 1.0.0
     */
    @Override
    public int updatePwd(Student student) {
        return studentMapper.updatePwd(student);
    }


    /**
     * @apiNote 增加学生
     * @param student 学生实体类
     * @author 武子砚
     * @email 2681413363@qq.com
     * @return int类型，受影响的条数
     * @since 1.0.0
     */
    @Override
    public int add(Student student) {
        return studentMapper.add(student);
    }
}
